<!DOCTYPE html>
<html lang="en">
<head>
<title>New Document</title>
<meta charset="utf-8">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="${webRoot}resources/css/bootstrap.min.css" rel="stylesheet"
	media="screen">
<link href="${webRoot}resources/css/style.css" rel="stylesheet">
</head>
<body class="main">
	<ul class="breadcrumb">
		<li><span id="test">您当前的位置：</span><a href="#">首页</a> <span
			class="divider">>></span></li>
		<li class="active">${ad}</li>
	</ul>
	<div id="div">
		<div class="wrap index-slider">
			<h6>广告</h6>
			<table class="table table-bordered">
				<thead>
					<tr>
						<th>商铺名称</th>
						<th>图片</th>
						<th>链接</th>
						<th>描述</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<#if adverEntitys?exists> <#list adverEntitys as ad>
					<tr>
						<td><#if ad.goods_Name?exists>${ad.goods_Name}</#if></td>
						<td><#if ad.adver_Image?exists><img alt=""
							src="${ad.adver_Image}" width="100px" height="100px"></#if>
						</td>
						<td><#if ad.adver_Image?exists>${ad.adver_Image}</#if></td>
						<td><#if ad.adver_Desc?exists>${ad.adver_Desc}</#if></td>
						<td><a href="">编辑</a><a
							href="javascript:deleteHref(${ad.adver_Id})">删除</a></td>
					</tr>
					</#list> </#if>
				</tbody>
			</table>
			<#if adverEntitys?exists>
			<div class="pagination pagination-right">
				<input type="hidden" name="userSelectBean" id="userSelectBean"
					value="${userEntity}" /> <input type="hidden" name="pageEntity"
					id="pageEntity" value="${pageEntity}" />
				<ul>
					<#if pageEntity.page==1>
					<li class="disabled"><a href="#">&laquo;</a></li> <#else>
					<li><a
						href="javascript:pageHref(${pageEntity.page-1},${pageEntity.totalPage},${pageEntity.pageSize})">&laquo;</a></li>
					</#if> <#list 1..pageEntity.totalPage as i> <#if
					pageEntity.page==i>
					<li class="active"><a href="#">${i}</a></li> <#else>
					<li><a
						href="javascript:pageHref(${i},${pageEntity.totalPage},${pageEntity.pageSize})">${i}</a></li>
					</#if> </#list> <#if pageEntity.page==pageEntity.totalPage>
					<li class="disabled"><a href="#">»</a></li> <#else>
					<li><a
						href="javascript:pageHref(${pageEntity.page+1},${pageEntity.totalPage},${pageEntity.pageSize})">»</a></li>
					</#if>
				</ul>
			</div>
			</#if>
		</div>
</div>

		<form class="form-horizontal" method="post"
			enctype="multipart/form-data"
			action="${webRoot}/web/manager/ad/add.do" id="form1">
			<div class="control-group">
				<label class="control-label" for="file">图片上传</label>
				<div class="controls">
					<input type="file" id="file" name="file">
					<div class="preview">
						<img src="">
					</div>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="adver_Position">类型</label>
				<div class="controls">
					<select class="select" id="adver_Position" name="adver_Position">
						<option value="s">开机启动页</option>
						<option value="a">首页</option>
					</select>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="adver_Desc">商铺名称</label>
				<div class="controls">
					<input type="text" id="goods_Id" name="goods_Name"
						placeholder="商铺名称">
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="adver_Desc">广告描述</label>
				<div class="controls">
					<input type="text" id="adver_Desc" name="adver_Desc"
						placeholder="图片描述">
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="adver_Seq">图片顺序</label>
				<div class="controls">
					<input type="number" id="adver_Seq" name="adver_Seq"
						placeholder="图片顺序">
				</div>
			</div>
			<div class="control-group">
				<div class="controls">
					<button type="button" class="btn" onclick="sendValue()">确认添加</button>
				</div>
			</div>
		</form>
	
	<script src="${webRoot}resources/js/jquery-1.9.2.min.js"></script>
	<script src="${webRoot}resources/js/bootstrap.min.js"></script>
	<script src="${webRoot}resources/js/js.js"></script>
	<script type="text/javascript">
		function sendValue() {
			var file = $("#file").val();
			var goods_Id = $("#goods_Id").val();
			var adver_Seq = $("#adver_Seq").val();

			if ($.trim(file) == null || $.trim(file) == "") {

				alert("广告图片不能为空");
				return;

			}
			if ($.trim(goods_Id) == null || $.trim(goods_Id) == "") {

				alert("商铺名称不能为空");
				return;

			}
			if ($.trim(adver_Seq) == null || $.trim(adver_Seq) == "") {

				alert("图片顺序不能为空");
				return;
			}
			$('#form1').submit();
		}

		function pageHref(page, totalPage, pageSize) {

			$.ajax({
				url : "${webRoot}/web/manager/ad/page.do?page=" + page
						+ "&pageSize=" + pageSize + "&totalPage=" + totalPage,
				type : "post",
				cache : "false",
				error : function() {
					alert("系统繁忙，请稍后再试！");
				},
				success : function(msg) {
					$("#div").html(msg);
				}
			});
		}

		function deleteHref(id) {

			$.ajax({
				url : "${webRoot}/web/manager/ad/delete.do?adver_Id=" + id,
				type : "post",
				cache : "false",
				error : function() {
					alert("系统繁忙，请稍后再试！");
				},
				success : function(msg) {
					$("#div").html(msg);
				}
			});
		}
	</script>
</body>
</html>
